import { HttpAdapterHost, NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import { AllFilter } from './common/filters/all-exception.filter';
import { GlobalGuard } from './common/guards/global.guard';
import { GlobalInterceptor } from './common/interceptors/global.interceptor';
// import { GlobalExceptionFilter } from './common/filters/global-exception.filter';
import { globalFnMiddleware } from './common/middleware/global-middleware/global-fn.middleware';
import { GlobalPipe } from './common/pipes/global.pipe';
// import { GlobalMiddleware } from './common/middleware/global-middleware/global.middleware';

async function bootstrap() {
  const app = await NestFactory.create(AppModule);
  // app.use(GlobalMiddleware);
  app.use(globalFnMiddleware);
  // app.useGlobalFilters(new GlobalExceptionFilter());
  const httpAdapter = app.get(HttpAdapterHost);
  app.useGlobalFilters(new AllFilter(httpAdapter));
  app.useGlobalPipes(new GlobalPipe());
  app.useGlobalGuards(new GlobalGuard());
  app.useGlobalInterceptors(new GlobalInterceptor('global'));
  await app.listen(3000);
}
bootstrap();
